<!--
 * @Author: wangding
 * @Date: 2020-11-11 15:58:31
 * @LastEditTime: 2021-01-12 16:51:06
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \solaxcloud\src\views\device\sale\add.vue
-->
<template>
    <div class="buyPage-main-box-add">
        <el-dialog
        :title="$t('import')"
        :visible="visibleAdd"
        width="40%"
        @close="()=>{$store.commit('setVisibleAdd',false)}"
        :close-on-click-modal='false'
        >
            <el-row :gutter="20">
                <el-col :span="17" :offset="2">
                    <div class="red">* {{$t('importantExcelPrompt')}}:{{$t('deviceTest.importantExcel.info')}}</div>
                </el-col>
                <el-col :span="17" :offset="2">
                    <el-form ref="form" :model="form" label-width="120px" >
                        <el-form-item :label="$t('version.versionService.fileURL')" prop="file" :rules="[{ required: true, message: $t('index_js_notNull')}]">
                            <fileInput v-model="form.file" ></fileInput>
                        </el-form-item>
                    </el-form>
                </el-col>
            </el-row>
            <span slot="footer" class="dialog-footer">
                <el-button @click="()=>{$store.commit('setVisibleAdd',false)}">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="save('form')">{{$t('sure')}}</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import fileInput from '../../../components/common/baseFileInput'
export default {
    components: {
        fileInput
    },
    props: {
        addname:{
            type:String,
            default:''
        },
        houseId:{
            type:String,
            default:''
        }
    },
    data() {
        return {
            form:{
                file:"",
            },
            flag:false,
            serviceList:[]
        };
    },
    computed: {
        visibleAdd(){
            return this.$store.state.sysStore.visibleAdd
        }
    },
    watch: {
    },
    created() {

    },
    mounted() {
    },
    methods: {
        async deviceTestAdd(){
            let res = await this.API.deviceTestImportantTestExcel({
                file:this.form.file
            })
            if(this.comm.showMsg(res.success)){
                this.$store.commit('setVisibleAdd',false)
                this.$emit('uploadData',true)
            }
        },
        save(formName){
            this.$refs[formName].validate((valid) => {
              if (valid) {
                  this.deviceTestAdd()
              } else {
                console.log('error submit!!');
                return false;
              }
            });
        },
    },
};
</script>

<style  lang="less" >
.buyPage-main-box-add{
    .el-form-item__content{
        display: flex;
    }
    .icon-fontsize{
        font-size: 25px;
        margin-left: 10px;
        display: block;
        width: 25px;
        height: 33px;
    }
    .red{
        color: red;
        border: 1px dashed red;
        margin-bottom: 25px;
        text-align: center;
    }
}
</style>
